﻿using System;
using Sys;
using System.Silverlight;
using seh=Sys.EventHandler;
using sea = Sys.EventArgs;
using System.Silverlight.Presentation;

namespace SBT
{
    public class Translatable : AgBehavior
    {
        private TranslateTransform m_translateTransform;
        public double TranslateX
        {
            get
            {
                return m_translateTransform.X;
            }
            set
            {
                if (m_translateTransform.X != value)
                {
                    m_translateTransform.X = value;
                    if (MultiBehavior != null)
                        MultiBehavior.RaiseEvent("translateXChanged");
                    else
                        RaiseEvent("translateXChanged");
                }
            }
        }
        public void add_translateXChanged(seh handler)
        {
            Events.AddHandler("translateXChanged", handler);
        }
        public void remove_translateXChanged(seh handler)
        {
            Events.RemoveHandler("translateXChanged", handler);
        }

        public double TranslateY
        {
            get
            {
                return m_translateTransform.Y;
            }
            set
            {
                if (m_translateTransform.Y != value)
                {
                    m_translateTransform.Y = value;
                    if (MultiBehavior != null)
                        MultiBehavior.RaiseEvent("translateYChanged");
                    else
                        RaiseEvent("translateYChanged");
                }
            }
        }
        public void add_translateYChanged(seh handler)
        {
            Events.AddHandler("translateYChanged", handler);
        }
        public void remove_translateYChanged(seh handler)
        {
            Events.RemoveHandler("translateYChanged", handler);
        }
        public override void Initialize()
        {
            base.Initialize();
            m_translateTransform = (TranslateTransform) Plugin.Content.CreateFromXaml("<TranslateTransform xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\" />");
            Element.RenderTransform = m_translateTransform;
        }
    }
}